#define GPI_BITMAP_SIZE sizeof(gpi_bitmap)
-#ifdef GPI_DBG
-# define PP warning("@%1$6x (%1$8d): ", gbftell(fin))
-# define dbginfo warning
-#else
-# define PP
-#endif
+#define GPI_DBG global_opts.debug_level >= 3
+#define PP if (GPI_DBG) warning("@%1$6x (%1$8d): ", gbftell(fin))
/*******************************************************************************
* %%% gpi reader %%% *
}
QString result = STRTOUNICODE(string).trimmed();
-#ifdef GPI_DBG
- dbginfo("%s: \"%s\"\n", field, result.isNull() ? "<NULL>" : qPrintable(result));
-#endif
+ if (GPI_DBG) {
+ warning("%s: \"%s\"\n", field, result.isNull() ? "<NULL>" : qPrintable(result));
+ }
return result;
}
GarminGPIFormat::read_header()
{
int len, i;
-#ifdef GPI_DBG
- struct tm tm;
- char stime[32];
-#endif
i = gbfgetint32(fin);
if (i != 0) {
PP;
rdata->crdate = gbfgetint32(fin);
-#ifdef GPI_DBG
- tm = *localtime(&rdata->crdate);
- tm.tm_year += 20; /* !!! */
- tm.tm_mday -= 1; /* !!! */
- strftime(stime, sizeof(stime), "%Y/%m/%d %H:%M:%S", &tm);
- dbginfo("crdate = %lu (%s)\n", rdata->crdate, stime);
-#endif
+ if (GPI_DBG) {
+ char stime[32];
+ struct tm tm = *localtime(&rdata->crdate);
+ tm.tm_year += 20; /* !!! */
+ tm.tm_mday -= 1; /* !!! */
+ strftime(stime, sizeof(stime), "%Y/%m/%d %H:%M:%S", &tm);
+ warning("crdate = %lu (%s)\n", rdata->crdate, stime);
+ }
(void) gbfgetint16(fin); /* 0 */
gbfread(&rdata->S8, 1, sizeof(rdata->S8) - 1, fin);
codepage = gbfgetuint16(fin);
-#ifdef GPI_DBG
- PP;
- dbginfo("Code Page: %d\n",codepage);
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("Code Page: %d\n",codepage);
+ }
(void) gbfgetint16(fin); /* typically 0, but 0x11 in
Garminonline.de files. */
-#ifdef GPI_DBG
- PP;
- dbginfo("< leaving header\n");
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("< leaving header\n");
+ }
}
/* read a single poi with all options */
void
GarminGPIFormat::read_poi(const int sz, const int tag)
{
-#ifdef GPI_DBG
- PP;
- dbginfo("> reading poi (size %d)\n", sz);
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("> reading poi (size %d)\n", sz);
+ }
PP;
int len = 0;
if (tag == 0x80002) {
len = gbfgetint32(fin); /* sub-header size */
}
-#ifdef GPI_DBG
- dbginfo("poi sublen = %1$d (0x%1$x)\n", len);
-#endif
+ if (GPI_DBG) {
+ warning("poi sublen = %1$d (0x%1$x)\n", len);
+ }
(void) len;
int pos = gbftell(fin);
waypt_add(wpt);
-#ifdef GPI_DBG
- PP;
- dbginfo("< leaving poi\n");
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("< leaving poi\n");
+ }
}
/* read poi's following a group header */
void
GarminGPIFormat::read_poi_list(const int sz)
{
- int i;
-
int pos = gbftell(fin);
-#ifdef GPI_DBG
- PP;
- dbginfo("> reading poi list (-> %1$x / %1$d )\n", pos + sz);
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("> reading poi list (-> %1$x / %1$d )\n", pos + sz);
+ }
PP;
- i = gbfgetint32(fin); /* mostly 23 (0x17) */
-#ifdef GPI_DBG
- dbginfo("list sublen = %1$d (0x%1$x)\n", i);
-#else
+ int i = gbfgetint32(fin); /* mostly 23 (0x17) */
+ if (GPI_DBG) {
+ warning("list sublen = %1$d (0x%1$x)\n", i);
+ }
(void) i;
-#endif
+
(void) gbfgetint32(fin); /* max-lat */
(void) gbfgetint32(fin); /* max-lon */
(void) gbfgetint32(fin); /* min-lat */
return;
}
}
-#ifdef GPI_DBG
- PP;
- dbginfo("< leaving poi list\n");
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("< leaving poi list\n");
+ }
}
void
GarminGPIFormat::read_poi_group(const int sz, const int tag)
{
int pos = gbftell(fin);
-#ifdef GPI_DBG
- PP;
- dbginfo("> reading poi group (-> %1$x / %1$d)\n", pos + sz);
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("> reading poi group (-> %1$x / %1$d)\n", pos + sz);
+ }
if (tag == 0x80009) {
PP;
int subsz = gbfgetint32(fin); /* ? offset to category data ? */
-#ifdef GPI_DBG
- dbginfo("group sublen = %d (-> %x / %d)\n", subsz, pos + subsz + 4, pos + subsz + 4);
-#else
+ if (GPI_DBG) {
+ warning("group sublen = %d (-> %x / %d)\n", subsz, pos + subsz + 4, pos + subsz + 4);
+ }
(void)subsz;
-#endif
}
rdata->group = gpi_read_string("Group");
}
}
-#ifdef GPI_DBG
- PP;
- dbginfo("< leaving poi group\n");
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("< leaving poi group\n");
+ }
}
// TODO: 'tag' is probably not a 32 bit value.
int sz = gbfgetint32(fin);
int pos = gbftell(fin);
-#ifdef GPI_DBG
- PP;
- dbginfo("%s: tag = 0x%x (size %d)\n", caller, tag, sz);
-#endif
+ if (GPI_DBG) {
+ PP;
+ warning("%s: tag = 0x%x (size %d)\n", caller, tag, sz);
+ }
if ((tag >= 0x80000) && (tag <= 0x800ff)) {
sz += 4;
}
case 0xb: /* as seen in German POI files. */
PP;
mask = gbfgetint16(fin); /* address fields mask */
-#ifdef GPI_DBG
- dbginfo("GPI Address field mask: %d (0x%02x)\n", mask, mask);
-#endif
+ if (GPI_DBG) {
+ warning("GPI Address field mask: %d (0x%02x)\n", mask, mask);
+ }
if ((mask & GPI_ADDR_CITY) && !(str = gpi_read_string("City")).isEmpty()) {
gmsd = gpi_gmsd_init(wpt);
garmin_fs_t::set_city(gmsd, str);
PP;
mask = gbfgetint16(fin); /* phone fields mask */
-#ifdef GPI_DBG
- dbginfo("GPI Phone field mask: %d (0x%02x)\n", mask, mask);
-#endif
+ if (GPI_DBG) {
+ warning("GPI Phone field mask: %d (0x%02x)\n", mask, mask);
+ }
if ((mask & 1) && !(str = gpi_read_string("Phone")).isEmpty()) {
gmsd = gpi_gmsd_init(wpt);
garmin_fs_t::set_phone_nr(gmsd, str);
case 0x11:
case 0x80007:
/* Looks like some kind of calendar information. */
-#ifdef GPI_DBG
- {
- int x;
- std::unique_ptr<unsigned char[]> b(new unsigned char[sz]);
- fprintf(stderr, "Tag: %x\n", tag);
- gbfread(b.get(), 1, sz, fin);
- fprintf(stderr, "\n");
- for (x = 0; x < sz; x++) {
- fprintf(stderr, "%02x ", b[x]);
- }
- fprintf(stderr, "\n");
- for (x = 0; x < sz; x++) {
- fprintf(stderr, "%c", isalnum(b[x]) ? b[x] : '.');
+ if (GPI_DBG) {
+ int x;
+ std::unique_ptr<unsigned char[]> b(new unsigned char[sz]);
+ fprintf(stderr, "Tag: %x\n", tag);
+ gbfread(b.get(), 1, sz, fin);
+ fprintf(stderr, "\n");
+ for (x = 0; x < sz; x++) {
+ fprintf(stderr, "%02x ", b[x]);
+ }
+ fprintf(stderr, "\n");
+ for (x = 0; x < sz; x++) {
+ fprintf(stderr, "%c", isalnum(b[x]) ? b[x] : '.');
+ }
+ fprintf(stderr, "\n");
}
- fprintf(stderr, "\n");
- }
-#endif // GPI_DBG
break;
default:
warning(MYNAME ": Unknown tag (0x%x). Please report!\n", tag);
src_h.used_colors = (src_h.image_offset - gbftell(f)) / 4;
}
-#ifdef GPI_DBG
- printf("data size: 0x%1$x (%1$d)\n", src_h.size);
- printf("image data offset: 0x%1$x (%1$d)\n", src_h.image_offset);
- printf("header size: 0x%1$x (%1$d)\n", src_h.header_size);
- printf("image width: 0x%1$x (%1$d)\n", src_h.width);
- printf("image height: 0x%1$x (%1$d)\n", src_h.height);
- printf("number of planes: 0x%1$x (%1$d)\n", src_h.planes);
- printf("bits per pixel: 0x%1$x (%1$d)\n", src_h.bpp);
- printf("compression type: 0x%1$x (%1$d)\n", src_h.compression_type);
- printf("image size: 0x%1$x (%1$d)\n", src_h.image_data_size);
- printf("horizontal resolution: 0x%1$x (%1$d)\n", src_h.resolution_h);
- printf("vertical resolution: 0x%1$x (%1$d)\n", src_h.resolution_v);
- printf("number of colors: 0x%1$x (%1$d)\n", src_h.used_colors);
- printf("important colors: 0x%1$x (%1$d)\n", src_h.important_colors);
-#endif
+ if (GPI_DBG) {
+ printf("data size: 0x%1$x (%1$d)\n", src_h.size);
+ printf("image data offset: 0x%1$x (%1$d)\n", src_h.image_offset);
+ printf("header size: 0x%1$x (%1$d)\n", src_h.header_size);
+ printf("image width: 0x%1$x (%1$d)\n", src_h.width);
+ printf("image height: 0x%1$x (%1$d)\n", src_h.height);
+ printf("number of planes: 0x%1$x (%1$d)\n", src_h.planes);
+ printf("bits per pixel: 0x%1$x (%1$d)\n", src_h.bpp);
+ printf("compression type: 0x%1$x (%1$d)\n", src_h.compression_type);
+ printf("image size: 0x%1$x (%1$d)\n", src_h.image_data_size);
+ printf("horizontal resolution: 0x%1$x (%1$d)\n", src_h.resolution_h);
+ printf("vertical resolution: 0x%1$x (%1$d)\n", src_h.resolution_v);
+ printf("number of colors: 0x%1$x (%1$d)\n", src_h.used_colors);
+ printf("important colors: 0x%1$x (%1$d)\n", src_h.important_colors);
+ }
/* sort out unsupported files */
if (!((src_h.width <= 24) && (src_h.height <= 24) &&